package cn.loan.controller;

import cn.loan.config.key.RequestKey;
import cn.loan.config.key.SessionKey;
import cn.loan.entity.User;
import cn.loan.service.ByStagesService;
import cn.loan.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

/**
 * @Author: 毛苏宇
 * @Description: 我的 页面
 * @Date: Create in 12:24 2019/3/20
 */
@Controller
@RequestMapping("/me")
public class MyInformationContoller {

    @Autowired private UserService userService;
    @Autowired private ByStagesService byStagesService;

    /**
     * 跳转到我的信息页面
     * @return 跳转到我的
     */
    @GetMapping("/myinfo")
    public String myInformation(HttpServletRequest request,HttpSession session){
        User user = (User) session.getAttribute(SessionKey.SESSION_USER);  //得到用户
        int userId = user.getUser_id(); //得到用户id
        User myInfo = userService.getMyInfo(userId);
        request.setAttribute(RequestKey.REQUEST_MY_INFO,myInfo);
        return "/MyInformation";
    }

}
